package org.smartboot.flow.testcase.adapter;

import org.smartboot.flow.core.Adapter;
import org.smartboot.flow.core.EngineContext;
import org.smartboot.flow.core.common.Pair;
import org.springframework.stereotype.Service;

/**
 * @author huqiang
 * @since 2022/12/7 19:54
 */
@Service
public class ExampleAdapter implements Adapter<Integer, Integer, Integer, Integer> {

    @Override
    public Pair<Integer, Integer> before(EngineContext<Integer, Integer> context) {
        return Pair.of(1, 2);
    }

    @Override
    public void after(EngineContext<Integer, Integer> origin, EngineContext<Integer, Integer> newContext) {
        System.out.println("origin req = " + origin.getReq() + ",  origin response = " + origin.getResult());
        System.out.println("req=" + newContext.getReq() + ",  response=" + newContext.getResult());
    }

    @Override
    public String describe() {
        return this.getClass().getName();
    }
}
